﻿using System.Reflection.Emit;

namespace Aeon.Emulator.Decoding.Emitters
{
    /// <summary>
    /// Contains common initialization information for decoder emitters.
    /// </summary>
    internal sealed class EmitStateInfo
    {
        #region Constructors
        /// <summary>
        /// Initializes a new instance fo the EmitStateInfo class.
        /// </summary>
        /// <param name="il">Current ILGenerator instance.</param>
        /// <param name="processorLocal">Processor local variable.</param>
        /// <param name="wordSize">Current processor word size.</param>
        /// <param name="returnType">Indicates whether values are returned by value or by address.</param>
        /// <param name="addressMode">Current addressing mode; must be either 16 or 32.</param>
        public EmitStateInfo(ILGenerator il, LocalBuilder processorLocal, int wordSize, EmitReturnType returnType, int addressMode)
        {
            this.IL = il;
            this.WordSize = wordSize;
            this.ProcessorLocal = processorLocal;
            this.ReturnType = returnType;
            this.AddressMode = addressMode;
        }
        #endregion

        #region Public Properties
        /// <summary>
        /// Gets the current ILGenerator instance.
        /// </summary>
        public ILGenerator IL { get; private set; }
        /// <summary>
        /// Gets the processor local variable.
        /// </summary>
        public LocalBuilder ProcessorLocal { get; private set; }
        /// <summary>
        /// Gets the current processor word size.
        /// </summary>
        public int WordSize { get; private set; }
        /// <summary>
        /// Gets a value indicating whether values are returned by value or by address.
        /// </summary>
        public EmitReturnType ReturnType { get; private set; }
        /// <summary>
        /// Gets the current addressing mode; this will be either 16 or 32.
        /// </summary>
        public int AddressMode { get; private set; }
        #endregion
    }
}
